qinglan.Canvas.Color = qinglan.Canvas.Class(function(r, g, b, a) {
	this.r = r;
	this.g = g;
	this.b = b;
	this.a = a;
}).methods({
	copy: function() {
		return new qinglan.Canvas.Color(this.r, this.g, this.b, this.a);
	},
	add: function(c) {
		return new qinglan.Canvas.Color(this.r + c.r, this.g + c.g, this.b + c.b, this.a + c.a);
	},
	multiply: function(s) {
		return new qinglan.Canvas.Color(this.r * s, this.g * s, this.b * s, this.a * s);
	},
	modulate: function(c) {
		return new qinglan.Canvas.Color(this.r * c.r, this.g * c.g, this.b * c.b, this.a * c.a);
	},
	saturate: function() {
		this.r = Math.min(this.r, 1);
		this.g = Math.min(this.g, 1);
		this.b = Math.min(this.b, 1);
		this.a = Math.min(this.a, 1);
	},
	isAlphaZero: function(){
		return 0 === this.a;  
	},
	getColorString: function() {
		return "rgba(" + Math.floor(this.r * 255) + "," + Math.floor(this.g * 255) + "," + Math.floor(this.b * 255) + "," + this.a.toFixed(2) + ")";
	}
});
qinglan.Canvas.Color.black = new qinglan.Canvas.Color(0, 0, 0, 1);
qinglan.Canvas.Color.white = new qinglan.Canvas.Color(1, 1, 1, 1);
qinglan.Canvas.Color.red = new qinglan.Canvas.Color(1, 0, 0, 1);
qinglan.Canvas.Color.green = new qinglan.Canvas.Color(0, 1, 0, 1);
qinglan.Canvas.Color.blue = new qinglan.Canvas.Color(0, 0, 1, 1);
qinglan.Canvas.Color.yellow = new qinglan.Canvas.Color(1, 1, 0, 1);
qinglan.Canvas.Color.cyan = new qinglan.Canvas.Color(0, 1, 1, 1);
qinglan.Canvas.Color.purple = new qinglan.Canvas.Color(1, 0, 1, 1);
